import React, { useState, useEffect } from 'react';
import { getWindowHeight, getPlatform } from '@UTILS/common'

const { isWeb } = getPlatform()

type ReturnType = number

const useGetWindowHeight = (showTabBar?: boolean): ReturnType => {
  const [height, setHeight] = useState<ReturnType>(500)

  useEffect(() => {
    const showBar = typeof showTabBar === 'undefined' ? isWeb : showTabBar
    setHeight(getWindowHeight(showBar))
  }, [showTabBar])

  return height
}

export default useGetWindowHeight
